package 力扣日常刷题.木22一月.第16天0128;

/**
 * @author 帅小伙
 * @date 2022/1/28
 * @description 状态可以用二进制表示
 */
public class Demo18字符串简单环和杆 {

    public static void main(String[] args) {
        countPoints("B0R0G0R9R0B0G0");
    }

    public static int countPoints(String rings) {
        int[] arr = new int[10];
        int len = rings.length();
        for (int i = 0; i < len; i += 2) {
            if (rings.charAt(i) == 'R') arr[rings.charAt(i + 1) - '0'] |= 1;
            if (rings.charAt(i) == 'G') arr[rings.charAt(i + 1) - '0'] |= 2;
            if (rings.charAt(i) == 'B') arr[rings.charAt(i + 1) - '0'] |= 4;
        }
        int ans = 0;
        for (int i = 0; i < 10; i++) {
            if (arr[i] == 7) ans++;
        }
        return ans;
    }
}
